package com.fc.test.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.fc.test.common.base.BaseService;
import com.fc.test.common.support.Convert;
import com.fc.test.mapper.auto.TAbbKefuMapper;
import com.fc.test.model.auto.TAbbKefu;
import com.fc.test.model.auto.TAbbKefuExample;
import com.fc.test.model.custom.Tablepar;
import com.fc.test.util.SnowflakeIdWorker;

/**
 * Service
* @Title: TAbbKefuService.java 
* @Package com.fc.test.entity 
* @author fuce
* @email 87766867@qq.com
* @date 2019-08-13 11:08:41  
 */
@Service
public class TAbbKefuService implements BaseService<TAbbKefu, TAbbKefuExample>{
	@Autowired
	private TAbbKefuMapper tAbbKefuMapper;
	
	/**
	 * 分页查询
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	 public PageInfo<TAbbKefu> list(Tablepar tablepar,String name){
	        TAbbKefuExample testExample=new TAbbKefuExample();
	        testExample.setOrderByClause("id ASC");
	        if(name!=null&&!"".equals(name)){
	        	testExample.createCriteria().andNameLike("%"+name+"%");
	        }

	        PageHelper.startPage(tablepar.getPageNum(), tablepar.getPageSize());
	        List<TAbbKefu> list= tAbbKefuMapper.selectByExample(testExample);
	        PageInfo<TAbbKefu> pageInfo = new PageInfo<TAbbKefu>(list);
	        return  pageInfo;
	 }

	@Override
	public int deleteByPrimaryKey(String ids) {
		List<String> lista=Convert.toListStrArray(ids);
		TAbbKefuExample example=new TAbbKefuExample();
		example.createCriteria().andIdIn(lista);
		return tAbbKefuMapper.deleteByExample(example);
	}
	
	
	@Override
	public TAbbKefu selectByPrimaryKey(String id) {
		
		return tAbbKefuMapper.selectByPrimaryKey(id);
	}

	
	@Override
	public int updateByPrimaryKeySelective(TAbbKefu record) {
		return tAbbKefuMapper.updateByPrimaryKeySelective(record);
	}
	
	/**
	 * 添加
	 */
	@Override
	public int insertSelective(TAbbKefu record) {
		//添加雪花主键id
		record.setId(SnowflakeIdWorker.getUUID());
		return tAbbKefuMapper.insertSelective(record);
	}
	
	

	

	
	
	

	
	@Override
	public int updateByExampleSelective(TAbbKefu record, TAbbKefuExample example) {
		
		return tAbbKefuMapper.updateByExampleSelective(record, example);
	}

	
	@Override
	public int updateByExample(TAbbKefu record, TAbbKefuExample example) {
		
		return tAbbKefuMapper.updateByExample(record, example);
	}

	@Override
	public List<TAbbKefu> selectByExample(TAbbKefuExample example) {
		
		return tAbbKefuMapper.selectByExample(example);
	}

	
	@Override
	public long countByExample(TAbbKefuExample example) {
		
		return tAbbKefuMapper.countByExample(example);
	}

	
	@Override
	public int deleteByExample(TAbbKefuExample example) {
		
		return tAbbKefuMapper.deleteByExample(example);
	}
	
	/**
	 * 检查name
	 * @param TAbbKefu
	 * @return
	 */
	public int checkNameUnique(TAbbKefu tAbbKefu){
		TAbbKefuExample example=new TAbbKefuExample();
		example.createCriteria().andNameEqualTo(tAbbKefu.getName());
		List<TAbbKefu> list=tAbbKefuMapper.selectByExample(example);
		return list.size();
	}


	public List<TAbbKefu> getKefuList(){
		List<TAbbKefu> list = tAbbKefuMapper.getKefuList();
		return list;
	}


}
